using Avalonia.Data.Converters;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AvaMaid.Neo.Converters
{
    public class FileToFileNameConverter : IValueConverter
    {
        public static FileToFileNameConverter Instance => _instance.Value;
        private static Lazy<FileToFileNameConverter> _instance = new Lazy<FileToFileNameConverter>();

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (value is string)
            {
                var svalue = (string)value;
                return Path.GetFileName(svalue);
            }
            else if (value is Uri)
            {
                var uvalue = (Uri)value;
                return Path.GetFileName(uvalue.LocalPath);
            }
            return string.Empty;
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
